<template>
	<view class="content">
		<view class="content-top">
			<view class='cell-group margin-cell-group'>
				<!-- <view class='cell-item'>
					<view class='cell-item-hd'>
						<view class='cell-hd-title'>当前积分</view>
					</view>
					<view class='cell-item-bd'>
						<text class="cell-bd-view">￥{{wallet.user_money}}</text>
					</view>
				</view> -->
				<view class="code" style="padding: 0 50rpx;">
					<view class="wechat" style="text-align: center;width: 100%;">
						<p class="text" style="margin-bottom: 20rpx;margin-top: 20rpx;">扫描二维码,向我充值</p>
						<p class="text" style="margin-bottom: 20rpx;margin-top: 20rpx;">RTX通道</p>
						<image src="http://www.zhongkeyun.live/uploads/images/202111011738285bdf38956.jpg" style="width: 500rpx;height: 1000rpx;margin-bottom: 20rpx;"></image>
						<p class="text" style="margin-bottom: 20rpx;">{{codes}}</p>
						<u-button  @click="onCopy(codes)" style="margin-bottom: 20rpx;">
						   
						    复制地址
						</u-button>
					</view>
					<!-- <view class="alipay">
						<p class="text">微信收款码</p>
						<u-image width="300rpx" height="300rpx" :src="alipay_img"></u-image>
					</view> -->
				</view>
				<view class='cell-item'>
					<view class='cell-item-hd'>
						<view class='cell-hd-title'>上传支付截图</view>
					</view>
				</view>
				<view class="Photo" style="border: 1px solid #0081FF; width: 80%;margin: 0 auto;">
					<u-upload ref="uUpload" :action="action" :max-count="1" :height="350" :width="580"
						@on-success="success"></u-upload>
				</view>
				<view class='cell-item'>
					<view class='cell-item-hd'>
						<view class='cell-hd-title'>充值U</view>
					</view>
					<view class='cell-item-bd'>
						<input class='cell-bd-input' placeholder='请输入要充值U的数量' v-model="money" focus type="digit"></input>
					</view>
				</view>
				<view class='cell-item'>
					
				</view>
			</view>
		</view>
		<view class="button-bottom">
			<button class="btn btn-square btn-b" hover-class="btn-hover2" @click="navigateToHandle">充值</button>
		</view>
	</view>
</template>

<script>
	import {
		getWallet,
		transferPoints,
		addRecharge
	} from '@/api/user';
	import {
		getConfig
	} from '@/api/app';
	import {
		imgURL
	} from '@/config/app';
	import {copy} from '@/utils/tools'
	export default {
		data() {
			return {
				action: 'http://www.zhongkeyun.live/api/new_recharge/getFile',
				// user: {}, // 用户信息
				money: '', // 转账积分
				wallet: {}, // 用户信息
				iPhone: "",
				wechat_img: "http://www.zhongkeyun.live/uploads/images/2021110318565822a694758.jpg",
				alipay_img: "",
				codes:""
			}
		},
		onLoad() {
			this.getWallets()
		},
		methods: {
			onCopy(str) {
			    copy(str);
			},
			success(data, index, lists, name) {
				console.log(data)
				this.file_id = data.data.file_id
			},
			// 获取用户信息
			getWallets() {
				getConfig().then(res => {
					console.log(res)
					this.wechat_img = imgURL + res.data.wechat_code
					console.log(this.wechat_img)
					// this.alipay_img = imgURL + res.data.alipay_code
					this.codes=res.data.pay_code
				});
			},
			// 去充值
			navigateToHandle() {
				if (!Number(this.money)) {
					// this.$common.errorToShow('请输入要充值的金额')
					uni.showToast({
						title: '请输入要充值的金额',
						duration: 2000,
						icon: "none"
					});
				} else {
					let data = {
						money: this.money,
						file_id: this.file_id
					}
					addRecharge(data).then(res => {
						if (res.code == 1) {
							console.log(res)
							uni.showToast({
								title: res.msg,
								icon: "none"
							});
							setTimeout(function() {
								uni.redirectTo({
									url: "../user_wallet/user_wallet"
								})
							}, 2000);

						}
					});

				}
			}
		}
	}
</script>

<style lang="less">
	.user-head {
		height: 100upx;
	}

	.user-head-img {
		height: 90upx;
		width: 90upx;
		border-radius: 50%;
	}

	.cell-hd-title {
		color: #333;
	}

	.cell-item-bd {
		color: #666;
		font-size: 26upx;
	}

	.button-bottom .btn {
		width: 100%;
	}

	.code {
		width: 100%;
		// display: flex;
		// text-align: center;
		// justify-content: space-between;

		.text {
			font-size: 30rpx;
			text-align: center;
		}
	}
</style>
